#import "ZQTabBarController.h"
#import "UIImage+Image.h"
#import "ZQTabBar.h"
#import "ZQNavViewController.h"
#import "ZQNewPage.h"
#import "ZQVideoTableViewPage.h"
#import "ZQWordPage.h"
@interface ZQTabBarController ()
@end
@implementation ZQTabBarController
+ (void)load
{
    UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor blackColor];
    [item setTitleTextAttributes:attrs forState:UIControlStateSelected];
    NSMutableDictionary *attrFot = [NSMutableDictionary dictionary];
    attrFot[NSFontAttributeName] = [UIFont systemFontOfSize:13 ];
    [item setTitleTextAttributes:attrFot forState:UIControlStateNormal];
}
#pragma mark - 生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setAllChildViewControllers];
    [self setAllChildTitleButton];
    [self settabbarView];
}
#pragma mark - set自定义的tabbar
- (void)settabbarView
{
    ZQTabBar *tabBarNew = [[ZQTabBar alloc]init];
    [self setValue:tabBarNew forKeyPath:@"tabBar"];
}
#pragma mark - 添加所有的子控制器
- (void)setAllChildViewControllers
{
    ZQVideoTableViewPage *videoPage = [ZQVideoTableViewPage new];
    ZQNavViewController *nav1 = [[ZQNavViewController alloc]initWithRootViewController:videoPage];
    [self addChildViewController:nav1];
    ZQNewPage *newPage = [ZQNewPage new];
    ZQNavViewController *nav2 = [[ZQNavViewController alloc]initWithRootViewController:newPage];
    [self addChildViewController:nav2];
    ZQWordPage *wordPage = [ZQWordPage new];
    ZQNavViewController *nav3 = [[ZQNavViewController alloc]initWithRootViewController:wordPage];
    [self addChildViewController:nav3];
}
- (void)setAllChildTitleButton
{
    UINavigationController *nav1 = self.childViewControllers[0];
    nav1.tabBarItem.title  = @"首页";
    nav1.tabBarItem.image= [UIImage imageNamed:@"tabBar_essence_icon"];
    nav1.tabBarItem.selectedImage = [UIImage imageOriginalWithName:@"tabBar_essence_click_icon"];
    UINavigationController *nav2 = self.childViewControllers[1];
    nav2.tabBarItem.title  = @"新闻";
    nav2.tabBarItem.image= [UIImage imageNamed:@"tabBar_new_icon"];
    nav2.tabBarItem.selectedImage = [UIImage imageOriginalWithName:@"tabBar_new_click_icon"];
      UINavigationController *nav3 = self.childViewControllers[2];
    nav3.tabBarItem.title  = @"段子";
    nav3.tabBarItem.image= [UIImage imageNamed:@"tabBar_friendTrends_icon"];
    nav3.tabBarItem.selectedImage = [UIImage imageOriginalWithName:@"tabBar_friendTrends_click_icon"];
}
@end
